package com.itheima.group;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;

public class Server {
    public static void main(String[] args) throws IOException {
        MulticastSocket ms = new MulticastSocket(10010);

        byte[] bytes = new byte[1024];
        InetAddress byName = InetAddress.getByName("224.0.1.0");
        DatagramPacket datagramPacket = new DatagramPacket(bytes,bytes.length);
        ms.joinGroup(byName);
        ms.receive(datagramPacket);
        byte[] data = datagramPacket.getData();
        int length = datagramPacket.getLength();
        System.out.println(new String(data, 0, length));
        ms.close();
    }
}
